//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package sto.android.app;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.provider.Settings.System;
import android.telephony.TelephonyManager;
import android.util.Log;
import sto.android.app.StoJNI;
import sto.android.app.StoJNI.ScanCallBack;

public class WangFengJNI implements StoJNI {
    private static WangFengJNI wangfengJNI;
    private static String TAG = "wangfengJNI";
    private Context mContext;
    ScanCallBack mScanCB;
    String mScanCode;
    private static final String NLS_MT60 = "NLS-MT60";
    private static final String MT60 = "MT60";
    private String model;
    public static String year = "";
    public static String month = "";
    public static String day = "";
    public static String hour = "";
    public static String minute = "";
    public static String second = "";
    public String UPtime;
    public static boolean m_isPowerOn = false;
    public static boolean m_isScanning = false;
    public static int mScanPower;
    public static int mScanMode;
    public static int mScanAutoEnter;
    public static int mScanNotySnd;
    public static int mScanNotyVib;
    public static int mScanNotyLed;
    public static int mScanTrigMode;
    public int mStatusBarExpand;
    public static final int SCANNER_CFG_SCAN_ENABLE = 1;
    public static final int SCANNER_CFG_SCAN_MODE = 2;
    public static final int SCANNER_CFG_AUTO_ENTER = 3;
    public static final int SCANNER_CFG_NOTY_SND = 4;
    public static final int SCANNER_CFG_NOTY_VIB = 5;
    public static final int SCANNER_CFG_NOTY_LED = 6;
    public static final int SCANNER_CFG_TRIG_MODE = 7;
    private BroadcastReceiver mReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            String scanResult = intent.getStringExtra("EXTRA_SCAN_DATA");
            String scanStatus = intent.getStringExtra("EXTRA_SCAN_STATE");
            if("ok".equals(scanStatus)) {
                WangFengJNI.this.ScanResults(scanResult, 1);
            } else {
                WangFengJNI.this.ScanResults(scanResult, 0);
            }

        }
    };

    private WangFengJNI(Context context) {
        this.model = Build.MODEL;
        this.mContext = context;
    }

    public static WangFengJNI getInstance(Context context) {
        if(wangfengJNI == null) {
            wangfengJNI = new WangFengJNI(context);
        }

        return wangfengJNI;
    }

    public void SetGPIOStatusJNI(int gpio, int status) {
    }

    public void SetScannerOn() {
        IntentFilter mFilter = new IntentFilter("ACTION_BAR_SCAN");
        if(this.mContext != null) {
            this.mContext.registerReceiver(this.mReceiver, mFilter);
        }

        new Intent();
        Intent tmpIntent = new Intent("ACTION_STO_EXTRA_POWER_ON");
        this.mContext.sendBroadcast(tmpIntent);
        m_isPowerOn = true;
    }

    public void SetScannerStart() {
        if(m_isPowerOn) {
            Intent tmpIntent = new Intent("ACTION_BAR_TRIGSCAN");
            if(this.mContext != null) {
                this.mContext.sendBroadcast(tmpIntent);
                m_isScanning = true;
            }
        }

    }

    public void SetScannerStop() {
        if(m_isPowerOn) {
            Intent tmpIntent = new Intent("ACTION_BAR_TRIGSCAN");
            if(this.mContext != null) {
                this.mContext.sendBroadcast(tmpIntent);
                m_isScanning = false;
            }
        }

    }

    public void SetScannerOff() {
        Intent tmpIntent = new Intent("ACTION_STO_EXTRA_POWER_OFF");
        if(this.mContext != null) {
            this.mContext.sendBroadcast(tmpIntent);
        }

        m_isPowerOn = false;
        m_isScanning = false;
    }

    public int SetScannerPara(int para, int value) {
        byte ret = 0;
        Intent tmpIntent = new Intent("ACTION_BAR_SCANCFG");
        switch(para) {
        case 1:
            mScanPower = value;
            tmpIntent.putExtra("EXTRA_SCAN_POWER", mScanPower);
            break;
        case 2:
            mScanMode = value;
            tmpIntent.putExtra("EXTRA_SCAN_MODE", mScanMode);
            break;
        case 3:
            mScanAutoEnter = value;
            tmpIntent.putExtra("EXTRA_SCAN_AUTOENT", mScanAutoEnter);
            break;
        case 4:
            mScanNotySnd = value;
            tmpIntent.putExtra("EXTRA_SCAN_NOTY_SND", mScanNotySnd);
            break;
        case 5:
            mScanNotyVib = value;
            tmpIntent.putExtra("EXTRA_SCAN_NOTY_VIB", mScanNotyVib);
            break;
        case 6:
            mScanNotyLed = value;
            tmpIntent.putExtra("EXTRA_SCAN_NOTY_LED", mScanNotyLed);
            break;
        case 7:
            mScanTrigMode = value;
            tmpIntent.putExtra("EXTRA_TRIG_MODE", mScanTrigMode);
            break;
        default:
            ret = -1;
        }

        if(this.mContext != null && ret != -1) {
            this.mContext.sendBroadcast(tmpIntent);
        }

        return ret;
    }

    public int GetScannerPara(int para) {
        int ret;
        switch(para) {
        case 1:
            ret = mScanPower;
            break;
        case 2:
            ret = mScanMode;
            break;
        case 3:
            ret = mScanAutoEnter;
            break;
        case 4:
            ret = mScanNotySnd;
            break;
        case 5:
            ret = mScanNotyVib;
            break;
        case 6:
            ret = mScanNotyLed;
            break;
        case 7:
            ret = mScanTrigMode;
            break;
        default:
            ret = -1;
        }

        return ret;
    }

    public String SetScannerPara(String para, String value) {
        return null;
    }

    public String GetScannerPara(String para) {
        return null;
    }

    public void SetScannerRetriger() {
        Intent tmpIntent = new Intent("ACTION_BAR_TRIGSCAN");
        if(this.mContext != null) {
            this.mContext.sendBroadcast(tmpIntent);
            m_isScanning = true;
        }

    }

    public void SetScannerTimerOut(int sec) {
        Intent intent = new Intent("ACTION_BAR_TRIGSCAN");
        intent.putExtra("timeout", sec);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
            m_isScanning = true;
        }

    }

    public boolean GetScannerIsScanning() {
        return m_isScanning;
    }

    public int getmScanModel() {
        return System.getInt(this.mContext.getContentResolver(), "scanner_barcode_model", 0);
    }

    public void SetSystemReboot() {
        Intent it = new Intent("android.intent.action.SET_REBOOT");
        if(this.mContext != null) {
            this.mContext.sendBroadcast(it);
        }

    }

    public void SetSystemShutdown() {
        Intent it = new Intent("android.intent.action.SET_SHUTDOWN");
        if(this.mContext != null) {
            this.mContext.sendBroadcast(it);
        }

    }

    public void SetSystemTime(String mm) {
        Intent it = new Intent("android.intent.action.SET_TIME");
        it.putExtra("time", String.valueOf(mm));
        if(this.mContext != null) {
            this.mContext.sendBroadcast(it);
        }

    }

    public void SetMachineCode(String code) {
    }

    public String GetMachineCode() {
        TelephonyManager tm = (TelephonyManager)this.mContext.getSystemService("phone");
        if(tm.getDeviceId() == null) {
            return "巴枪ID为空";
        } else {
            Log.i("============id \t", tm.getDeviceId());
            return tm.getDeviceId();
        }
    }

    public void disableKeypad() {
        Intent intent = new Intent("com.android.action.HOMEKEY_SWITCH_STATE");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void disableKeypadEnableCustom(String customstr) {
    }

    public void enableKeypad() {
        Intent intent = new Intent("com.android.action.HOMEKEY_SWITCH_STATE");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void enableKeydownTone() {
        Intent intent = new Intent("com.android.action.KEYDOWN_TONE_STATE");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public int GetStatusKeydownTone() {
        return System.getInt(this.mContext.getContentResolver(), "sound_effects_enabled", 1);
    }

    public void disableKeydownTone() {
        Intent intent = new Intent("com.android.action.KEYDOWN_TONE_STATE");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void TurnOffStatusBarExpand() {
        Intent intent = new Intent("com.android.action.STATUSBAR_SWITCH_STATE");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
            this.mStatusBarExpand = 0;
        }

    }

    public int GetStatusBarExpand() {
        return this.mStatusBarExpand;
    }

    public void TurnOnStatusBarExpand() {
        Intent intent = new Intent("com.android.action.STATUSBAR_SWITCH_STATE");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
            this.mStatusBarExpand = 1;
        }

    }

    public void TurnOffUSBDebug() {
        Intent intent = new Intent("android.intent.action.USB_DEBUG_STATE");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public int GetStatusUSBDebug() {
        return System.getInt(this.mContext.getContentResolver(), "adb_enabled", 1);
    }

    public void TurnOnUSBDebug() {
        Intent intent = new Intent("android.intent.action.USB_DEBUG_STATE");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void TurnOffInstallManager() {
        Intent intent = new Intent("android.intent.action.SET_INSALL_MANAGER");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public int GetStatusInstallManager() {
        return System.getInt(this.mContext.getContentResolver(), "install_manager", 1);
    }

    public void TurnOnInstallManager() {
        Intent intent = new Intent("android.intent.action.SET_INSALL_MANAGER");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void TurnOnScreenLock() {
        Intent intent = new Intent("android.intent.action.LOCKSCREEN_STATE");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public int GetStatusScreenLock() {
        return System.getInt(this.mContext.getContentResolver(), "lockscreen_state", 1);
    }

    public void TurnOffScreenLock() {
        Intent intent = new Intent("android.intent.action.LOCKSCREEN_STATE");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public int GetStatusWakeUp() {
        return System.getInt(this.mContext.getContentResolver(), "anykey_wakeup", 0);
    }

    public void CfgPowerKeyWakeUp() {
        Intent intent = new Intent("android.intent.action.ANYKEY_WAKEUP_STATE");
        intent.putExtra("enable", false);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void CfgAnyKeyWakeUp() {
        Intent intent = new Intent("android.intent.action.ANYKEY_WAKEUP_STATE");
        intent.putExtra("enable", true);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void Disable_touch_screen() {
    }

    public void Enable_touch_screen() {
    }

    public int GetStatusTouch_screen() {
        return 0;
    }

    public void StoJNI_InstallApkWithSilence(String apkPath, boolean runAfterFinished) {
		Intent intent = new Intent("android.intent.action.INSTALL_APK_SILENCE");
		intent.putExtra("InstallPath", apkPath);
		intent.putExtra("RunAfterFinsh", runAfterFinished);
		if (mContext != null) {
			mContext.sendBroadcast(intent);			
		}

		
    }

    public void TurnOnOffGPS(boolean set) {
        Intent intent = new Intent("android.intent.action.GPS_STATE");
        intent.putExtra("enable", set);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void TurnOnOffBrowser(boolean set) {
        Intent intent = new Intent("android.intent.action.BROWSER_STATE");
        intent.putExtra("enable", set);
        if(this.mContext != null) {
            this.mContext.sendBroadcast(intent);
        }

    }

    public void setmScanCB(ScanCallBack mScanCB) {
        this.mScanCB = mScanCB;
    }

    public void ScanResults(String str, int type) {
        java.lang.System.out.println("#############扫描结果" + str);
        if(this.mScanCB != null) {
            this.mScanCB.onScanResults(str, type);
            this.mScanCB.onScanResults(str);
            m_isScanning = false;
        }

    }

    public void ScanResults(String str) {
        java.lang.System.out.println("#############扫描结果" + str);
        if(this.mScanCB != null) {
            this.mScanCB.onScanResults(str);
            m_isScanning = false;
        }

    }

    public String getPdaBrand() {
        return "wangfeng";
    }

    public int getEventFuction(int keycode) {
        Log.d(TAG, "######" + TAG + "getEventFunction");
        switch(keycode) {
        case 3:
            return 3;
        case 4:
            return 4;
        case 5:
            return 5;
        case 6:
            return 6;
        case 7:
            return 7;
        case 8:
            return 8;
        case 9:
            return 9;
        case 10:
            return 10;
        case 11:
            return 11;
        case 12:
            return 12;
        case 13:
            return 13;
        case 14:
            return 14;
        case 15:
            return 15;
        case 16:
            return 16;
        case 19:
            return 19;
        case 20:
            return 20;
        case 21:
            return 21;
        case 22:
            return 22;
        case 24:
            return 134;
        case 25:
            return 133;
        case 56:
            return 17;
        case 61:
            return 61;
        case 66:
            return 66;
        case 67:
            return 67;
        case 69:
            return 18;
        case 82:
            return 82;
        case 131:
            return 131;
        case 132:
            return 132;
        case 136:
            return 140;
        case 139:
        case 140:
        case 141:
            return 110;
        default:
            return 0;
        }
    }

    public String getJniVer() {
        return "wangfeng-1.0.0.1";
    }

    public int getPlatform() {
        return 0;
    }

    public void Disable_home_touch_screen() {
    }

    public void Enable_home_touch_screen() {
    }

    public int GetStatusTouch_Home_screen() {
        return 0;
    }

    public void Disable_menu_touch_screen() {
    }

    public void Enable_menu_touch_screen() {
    }

    public int GetStatusTouch_Menu_screen() {
        return 0;
    }

    public void Disable_back_touch_screen() {
    }

    public void Enable_back_touch_screen() {
    }

    public int GetStatusTouch_Back_screen() {
        return 0;
    }
}
